package com.inspur.edp.cef.designtime.core.utilsgenerator;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ImportInfos {
    private List<String> importPackages=new ArrayList();

    public List<String> getImportPackages() {
        return importPackages;
    }

    public void addImportPackage(String value)
    {
        if(importPackages.contains(value))
            return;
        importPackages.add(value);
    }

    public void addImportPackage(TypeRefInfo typeRefInfo)
    {
        if("void".equals(typeRefInfo.getTypeName()))
            return ;
        if("java.lang".equals(typeRefInfo.getTypePackageName()))
            return;
        if(typeRefInfo.getTypePackageName()==null||"".equals(typeRefInfo.getTypePackageName()))
            return;
        if(importPackages.contains(typeRefInfo.getFullName()))
            return;
        importPackages.add(typeRefInfo.getFullName());
    }

    public void write(StringBuilder stringBuilder) {
        Collections.sort( getImportPackages());
              for (String value :getImportPackages() ) {
            stringBuilder.append("import " + value + ";\n");
        }
    }
}
